﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;


public partial class EditSMSSendDetail : Frame.Pages.FliterBIEditBasePage<DAL.BLI_SMS_SendDetail>, Frame.Pages.IDetailEditManPage<DAL.BI_Consumer>
{
    protected Frame.Pages.RefrenceContext<DAL.BI_Consumer> RefrenceContext
    {
        get
        {
            if (!string.IsNullOrEmpty(Request.QueryString["ConsumerID"]))
            {
                this.BackUrl = "~/SMSManage/EditSMSSendDetail.aspx";
                using (CMSDALDataContext dcontext = new CMSDALDataContext())
                {
                    Model = dcontext.BI_Consumer.FirstOrDefault(o => o.ConsumerID == int.Parse(Request.QueryString["ConsumerID"]));
                    if (Model == null)
                    {
                        Model = new BI_Consumer();
                    }
                }
                Frame.Pages.RefrenceContext<DAL.BI_Consumer>.UpdateCurrent(this);
            }
            else
            {
                Frame.Pages.RefrenceContext<DAL.BI_Consumer>.Clear();
            }
            return Frame.Pages.RefrenceContext<DAL.BI_Consumer>.Current;
        }
    }

    protected override Func<DAL.BLI_SMS_SendDetail, bool> FliterExpression
    {
        get
        {


            if (Frame.Pages.RefrenceContext<DAL.BI_Consumer>.Current != null)
            {
                return new Func<BLI_SMS_SendDetail, bool>(o => o.Consumer_ID == Frame.Pages.RefrenceContext<DAL.BI_Consumer>.Current.Model.ConsumerID);
            }
            else
            {
                return null;
            }

        }
    }

    protected override bool IsAddCommandColumn
    {
        get
        {
            return false;
        }
    }
    /// <summary>
    /// 权限编码，需要重新设置
    /// </summary>
    protected override string ActionID
    {
        get { return "0"; }
    }
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!IsPostBack && !IsCallback)
        {
            if (Frame.Pages.RefrenceContext<DAL.BI_Consumer>.Current != null)
            {
                Backlink.NavigateUrl = (Frame.Pages.RefrenceContext<DAL.BI_Consumer>.Current == null ? string.Empty : Frame.Pages.RefrenceContext<DAL.BI_Consumer>.Current.BackUrl);
                WebUtility.MappingConsumerView(Detailpanel, Frame.Pages.RefrenceContext<DAL.BI_Consumer>.Current.Model);
                this.gridView.Settings.ShowGroupPanel = false;
            }
            else
            {
                this.gridView.Settings.ShowGroupPanel = true;
                this.gridView.SettingsBehavior.AllowGroup = true;
                this.gridView.SettingsBehavior.AllowDragDrop = true;
                this.gridView.Columns["Consumer_ID"].Visible = true;
                this.gridView.SettingsText.GroupPanel = "将列名拖入此处进行分组！";
                this.Detailpanel.Visible = false;
                Backlink.Visible = false;
            }
        }

    }

    public string BackUrl
    {
        get;
        set;
    }

    public BI_Consumer Model
    {
        get;
        set;
    }

    public string ScriptBackUrl
    {
        get;
        set;
    }
}